<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style type="text/css">
            .d1{
                width: 200px;
                height: 200px;
                border: 1px solid blueviolet;
            }
        
        </style>
    </head>
    <body>
        <div class="d1"></div>

        <script type="text/javascript">
            const d1 = document.querySelector(".d1");

            d1.addEventListener("mouseover",function(){
                const xhr = new XMLHttpRequest();

                xhr.open("POST","http://127.0.0.1:8000/post-server?password=123456");//设置url参数
                //设置请求头信息
                xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                xhr.setRequestHeader("password","12345");
                //设置请求体信息
                xhr.send("username=wt");
                xhr.onreadystatechange = function(){
                    if(xhr.readyState === 4){
                        if(xhr.status >=200 && xhr.status <300){
                            d1.innerHTML += xhr.response;
                        }
                    }

                }

            });
        
        
        </script>
    </body>
</html>